package com.tanhua.dubbo.api;

import com.tanhua.model.mongo.Report;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;

import java.util.List;

/**
 * @Description:
 * @Create by: wanglei
 * @Date: 2021/11/8 15:05
 */
@DubboService
public class ReportApiImpl implements ReportApi {

    @Autowired
    private MongoTemplate mongoTemplate;

    //保存测试对象。
    @Override
    public void save(Report report) {
        mongoTemplate.save(report);
    }

    //根据reporetId查找
    @Override
    public Report findByReportId(Integer reporetId) {
        Query query = Query.query(Criteria.where("reportId").is(reporetId));
        Report report = mongoTemplate.findOne(query, Report.class);
        return report;
    }
}
